<%--
  Created by IntelliJ IDEA.
  User: zhongge
  Date: 2025/8/16
  Time: 0:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>编辑学生</title>
    <style>
        .container { width: 50%; margin: 20px auto; }
        .form-group { margin-bottom: 15px; }
        label { display: inline-block; width: 100px; }
        input, select, textarea { width: 300px; padding: 5px; }
        .btn { padding: 8px 15px; background-color: #2196F3; color: white; border: none; border-radius: 3px; cursor: pointer; }
        .back-btn { background-color: #ccc; color: #000; margin-left: 10px; }
        .delete-btn { background-color: #f44336; margin-left: 10px; }
        h1 { text-align: center; }
    </style>
</head>
<body>
<div class="container">
    <h1>编辑学生信息</h1>
    <form action="${pageContext.request.contextPath}/updateSave" method="post">
        <input type="hidden" name="id" value="${requestScope.student.id}">

        <div class="form-group">
            <label for="name">姓名：</label>
            <input type="text" id="name" name="name" value="${requestScope.student.name}" required>
        </div>

        <div class="form-group">
            <label for="age">年龄：</label>
            <input type="number" id="age" name="age" value="${requestScope.student.age}" min="0" required>
        </div>

        <div class="form-group">
            <label for="sex">性别：</label>
            <select id="sex" name="sex" required>
                <option value="1" ${requestScope.student.sex == 1 ? 'selected' : ''}>男</option>
                <option value="0" ${requestScope.student.sex == 0 ? 'selected' : ''}>女</option>
            </select>
        </div>

        <div class="form-group">
            <label for="birthday">生日：</label>
            <input type="date" id="birthday" name="birthday"
                   value="<fmt:formatDate value="${requestScope.student.birthday}" pattern="yyyy-MM-dd"/>" required>
        </div>

        <div class="form-group">
            <label for="address">地址：</label>
            <input type="text" id="address" name="address" value="${requestScope.student.address}" required>
        </div>

        <div class="form-group">
            <label for="remark">备注：</label>
            <textarea id="remark" name="remark" rows="3">${requestScope.student.remark}</textarea>
        </div>

        <div class="form-group">
            <label></label>
            <input type="submit" value="更新" class="btn">
            <a href="${pageContext.request.contextPath}/list" class="btn back-btn">返回列表</a>
        </div>
    </form>
</div>
</body>
</html>

